// The Swift Programming Language
// https://docs.swift.org/swift-book
import UIKit

public enum TAleartStyle {
    case TAlearTStyleCenterTwo
    case TAlearTStyleCenterOne
    case TAleartStyleButton
}

@MainActor public func show(superView:UIView,titel:String = "温馨提示",content:String = "提示内容",cancel:String = "取消",okbutton:String = "确定",style:TAleartStyle = .TAlearTStyleCenterTwo,okButtonClickHandler: ((String) -> Void)?){

    if style == .TAlearTStyleCenterTwo {
        let alertView = TLAleartView(frame: .zero, titel: titel, content: content, cancel: cancel, okStr: okbutton,style: .TAleartViewStyleCenterTwo)
        alertView.okBtnClickHandler = okButtonClickHandler
        superView.addSubview(alertView)
        alertView.snp.makeConstraints { make in
            make.left.bottom.right.top.equalTo(superView)
        }
    } else if style == .TAlearTStyleCenterOne {
        let alertView = TLAleartView(frame: .zero, titel: titel, content: content, cancel: cancel, okStr: okbutton,style: .TAleartViewStyleCenterOne)
        alertView.okBtnClickHandler = okButtonClickHandler
        superView.addSubview(alertView)
        alertView.snp.makeConstraints { make in
            make.left.bottom.right.top.equalTo(superView)
        }
    }
}

@MainActor
public func showbutton(superView: UIView, titel: String = "温馨提示", okButton: String = "确定", content: Array<String>, style: TAleartStyle = .TAleartStyleButton, okButtonClickHandler: ((String) -> Void)?) {
    if style == .TAleartStyleButton {
        let alertView = TLAleartViewButton(frame: .zero, titel: titel, centent: content)
        
        // 将 alertView 添加到 superView
        superView.addSubview(alertView)
        alertView.snp.makeConstraints { make in
            make.left.bottom.right.top.equalTo(superView)
        }
        
        alertView.okButtonClickHandler = okButtonClickHandler
        alertView.showWithAnimation()
    }
}
